<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
        <meta charset="UTF-8">
<link rel="stylesheet" href="${initParam.root}css/table.css" type="text/css">

<script type="text/javascript">
   $(document).ready(pageload);
         function pageload() {
      $("#List").change(function() {
        var order=$(this).val();
         if (order == "") {
            alert("정렬방식을 선택하세요.");
            return false;
         }
          var url="${initParam.root }common/find_DealByCategory.do?order="+order+"&category=${param.category }";
          $(location).attr('href',url);           
      });
   };
</script>

<c:choose>
<c:when test="${requestScope.dealList=='Empty'}">
<h2>상품이 없습니다.</h2>

</c:when>
<c:otherwise>
<div align="center">
<h2>전체상품 리스트</h2>
</div>
<input type="hidden" name="category" value="${param.category }" />
<table border="1" class="registerMemberTable"  style="margin: 0 auto ; width: auto" >
   <caption >
   <select id="List">
   <option value="">정렬선택</option>
    <option value="new">최근등록순</option>
    <option value="end">마감일순</option>
    <option value="lowprice">낮은가격순</option>
    <option value="highprice">높은가격순</option>
   </select>
   </caption>

      <tr>
         <th class="dealTitle">딜명</th>
         <th class="dealPrice">가격</th>
         <th class="dealCount">개수</th>
         <th class="dealEndDate">마감일</th>
         <th class="dealImage">이미지</th>
      </tr>
      <tbody id="dealView">
        <c:forEach var="list" items="${requestScope.list}">
       <tr>
            <td id="dealTitleId"><a href="${initParam.root }common/showDealContents.do?dealNumber=${list.dealNumber}">${list.dealTitle}</a></td>
            <td id="dealPriceId">${list.dealPrice }원</td>
            <td id="dealCountId">${list.dealCount }</td>
            <td id="dealEndDateId">${list.dealEndDate }</td>
            <td id="dealImageId"><c:choose><c:when test="${list.dealCount==0 }">
            <a href="${initParam.root }common/showDealContents.do?dealNumber=${list.dealNumber}"><img src="${initParam.root }upload/soldout.jpg" width="300px" height="300px"></a>
            </c:when>
                <c:otherwise><a href="${initParam.root }common/showDealContents.do?dealNumber=${list.dealNumber}">
               <img src="${initParam.root }upload/${list.dealImage }" width="300px" height="300px"></a>
            </c:otherwise>
            </c:choose>
            </td>
      </tr>
      </c:forEach>
         </tbody>
</table>
</c:otherwise>
</c:choose>